package com.atguigu.bigdata.spark.zzgcore.rdd.operator.transform

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @Classname Spark01_RDD_Operation_Transfrom
 * @Description TODO
 * @Date 2023/9/20 15:23
 * @Author zhuzhenguo
 */
object Spark04_RDD_Operation_Transform1 {
  def main(args: Array[String]): Unit = {
    // 准备环境,这个 *表示系统当前最大可用核数
    val sparkConf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("Operator")
    val sc = new SparkContext(sparkConf)
    val rdd: RDD[String] = sc.makeRDD(List(
      "hello scala", "hello world"
    ))
    // 返回可迭代的集合
    val flatRDD: RDD[String] = rdd.flatMap(
      s => s.split(" ")
    )

    flatRDD.collect().foreach(println)
    // 关闭环境
    sc.stop()
  }
}
